// Problem 195: Inscribed circles of triangles with one angle of 60 degrees
// Let's call an integer sided triangle with exactly one angle of 60 degrees a 60-degree triangle.
// Let r be the radius of the inscribed circle of such a 60-degree triangle.
// There are 1234 60-degree triangles for which r ≤ 100.
// Let T(n) be the number of 60-degree triangles for which r ≤ n, so
// T(100) = 1234,  T(1000) = 22767, and  T(10000) = 359912.
// Find T(1053779).

package main

import (
	"fmt"
	"math"
)

func p195() {
	//a*a=b*b+c*c-b*c
	//T(1000) in 4000000 7s
	LIMIT := 4000000
	N := 1000
	count := 0
	for b := 1; b < 3465; b++ {
		for m := 1; m < LIMIT; m++ {
			squareA := b*b + (b+m)*m
			if a := int(math.Sqrt(float64(squareA))); a*a == squareA {
				r2p4 := (2*b + m - a) * (a*a - m*m)
				if r2p4 < 4*N*N*(a+2*b+m) {
					//fmt.Printf("b=%d, m=%d\n", b, m)
					count++
				} else {
					break
				}
			} else if a == m+b/2 {
				break
			}
		}
	}
	fmt.Println("Problem 195:", count)
}
